package com.qf.controller;

import com.qf.entity.TlHotel;
import com.qf.service.AdminHotelService;
import com.qf.service.HotelService;
import com.qf.utils.QiNiuTools;
import com.qf.utils.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/AdminHotel")
public class AdminHotelController {
    @Autowired
    AdminHotelService adminHotelService;
    @Autowired
    QiNiuTools qiNiuTools;
    @GetMapping("/findAllHotel")
    public ResultMsg findAllHotel(@RequestParam(required = false,defaultValue = "1")int page, @RequestParam(required = false,defaultValue = "5")int limit){
        return adminHotelService.findAllHotel(page,limit);

    }
    @GetMapping("/findOne/{id}")
    public ResultMsg findOnebyId(@PathVariable("id") int hid){
        return adminHotelService.findone(hid);

    }
    @PostMapping("/update")
    public ResultMsg update(@RequestBody TlHotel hotel){
        return adminHotelService.update(hotel);

    }
    @PostMapping("/upload")
    public ResultMsg upload(MultipartFile file) {
        String upload = qiNiuTools.upload(file);
        return ResultMsg.SUCCESS(upload);
    }
    @GetMapping("/del")
    public ResultMsg del(int hid){
        return adminHotelService.delet(hid);

    }
}
